var FinishedCtrl = ['$scope', '$rootScope', 'ReceiptFinished', 'timeStamp2String', function ($scope, $rootScope, ReceiptFinished, timeStamp2String) {
		
        //获取需要日结单据
        $scope.search = function (date) {
            var time = timeStamp2String(date, 'date');
            ReceiptFinished.get_receipt_finished(time).then(function (ret) {
                //退货
                $scope.return = ret.return.data.data.data;
                //销货
                $scope.sales = ret.normal.data.data.data;
                //总计
                $scope.total = ret.total.data.data;
            });
        };
        $scope.date = new Date();
        var nowDay = timeStamp2String($scope.date, 'date');
        $scope.search(nowDay);

        //日结操作
        $scope.submit = function (summary, date, person) {
            //判断是否有交易记录
            if ($scope.return.length == 0 && $scope.sales.length == 0) {
                baison_app.api.toast({msg: $rootScope.language.TIP_FINISHED_ERROR});
                return;
            }
            var time = timeStamp2String(date, 'date');
            var param = {
                'time': time,
                'summary': summary
            };
            ReceiptFinished.submit_receipt_finished(param).then(function (ret) {
                baison_app.api.alert({buttons: [$rootScope.language.COMMON_CONFIRM_BUTTON], msg: $rootScope.language[ret.data.code]});
            }).then(function (success) {
                $scope.search(nowDay);
            });
        };
        //表格切换
        $scope.table01 = true;
        $scope.table02 = false;
        $scope.switch_table = function (arr) {

            if (arr == 'one') {
                $scope.table01 = true;
                $scope.table02 = false;
            } else {
                $scope.table01 = false;
                $scope.table02 = true;
            }
        };
    }];
FinishedCtrl.$injector = ['$scope', '$rootScope', 'ReceiptFinished', 'timeStamp2String'];